import React from "react";

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = { count: 0 };
  }

  componentDidMount() {
    console.log("111", this.state.count); // 输出: 0

    this.setState({ count: this.state.count + 1 });
    console.log("222", this.state.count); // 输出: 1

    this.setState({ count: this.state.count + 1 }, () => {
      console.log("333", this.state.count); // 输出: 2
    });
  }

  render() {
    return <div>Count: {this.state.count}</div>;
  }
}

export default MyComponent;
